import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 1. 输入顾客信息
        System.out.println("请输入顾客姓名：");
        String name = sc.next();
        System.out.println("请输入顾客电话：");
        String phone = sc.next();
        Customer customer = new Customer(name, phone);

        // 2. 准备菜品（将“热茶”改为“姜汁可乐”，保持库存0模拟缺货）
        Dish rice = new Staple("盖饭", 16, 10, "米饭");
        Dish noodles = new Staple("牛肉面", 15, 0, "面条"); // 牛肉面缺货
        Dish beer = new Beverage("啤酒",8, 5, true);
        //属性设为热饮（isCold=false），库存0（缺货）
        Dish gingerCola = new Beverage("姜汁可乐（扎）", 18, 0, false); 

        // 3. 打印菜单（更新菜品4为“姜汁可乐”）
        System.out.println("\n===== 菜单 =====");
        System.out.println("1. " + rice.getInfo());
        System.out.println("2. " + noodles.getInfo());
        System.out.println("3. " + beer.getInfo());
        System.out.println("4. " + gingerCola.getInfo()); // 显示新菜品
        System.out.println("0. 结束点餐");

        // 4. 创建订单
        Order order = new Order(customer);

        // 5. 循环接收用户点餐输入（仅修改case 4对应的菜品）
        while (true) {
            System.out.println("\n请输入要点的菜品编号（0结束）：");
            int choice = sc.nextInt();

            if (choice == 0) {
                break;
            }

            // 根据编号获取选中的菜品
            Dish selectedDish = null;
            switch (choice) {
                case 1:
                    selectedDish = rice;
                    break;
                case 2:
                    selectedDish = noodles;
                    break;
                case 3:
                    selectedDish = beer;
                    break;
                case 4:
                    selectedDish = gingerCola; // 关联新菜品
                    break;
                default:
                    System.out.println("错误：没有这个菜品编号");
                    continue;
            }

            // 缺货判断（逻辑不变）
            if (selectedDish.stock == 0) {
                System.out.println("抱歉：" + selectedDish.name + "已缺货，无法点餐");
                continue;
            }

            // 输入数量并点餐（更新case 4为姜汁可乐）
            System.out.println("请输入点餐数量：");
            int num = sc.nextInt();
            String result = "";
            switch (choice) {
                case 1:
                    result = order.addDish(rice, num);
                    break;
                case 2:
                    result = order.addDish(noodles, num);
                    break;
                case 3:
                    result = order.addDish(beer, num);
                    break;
                case 4:
                    result = order.addDish(gingerCola, num); // 关联新菜品
                    break;
            }
            System.out.println(result);
        }

        // 6. 打印最终订单
        System.out.println("\n===== 您的订单已生成 =====");
        order.printOrder();

        sc.close();
    }
}